<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <script src="../js/vue.js"></script>
    <script src="../js/axios.min.js"></script>
</head>

<body>
    <div id="app">
        用户名<input type="text" v-model="username">
        密码 <input type="text" v-model="userpwd">
        <button @click="login">登录</button>
    </div>

</body>
<script>
    new Vue({
        el: "#app",
        data: {
            username: "",
            userpwd: "",
        },
        methods: {
            async login() {
                if (this.username && this.userpwd) {


                    let { data } = await axios({
                        method: "get",
                        url: "http://localhost:2345/userinfo",
                        params: {
                            username: this.username,
                            userpwd: this.userpwd
                        }

                    })

                    if (data.length) {
                        alert("成功")
                    } else {
                        alert("用户名或者密码错误")
                    }


                }


            }

        }
    })



</script>

</html>